package com.es.www.kyl.controller.api;

import com.es.www.kyl.bean.R;
import com.es.www.kyl.bean.req.client.DoExerciseBaseReq;
import com.es.www.kyl.bean.req.client.ExerciseQueryReq;
import com.es.www.kyl.bean.req.client.ExerciseResultReq;
import com.es.www.kyl.bean.res.client.QuestionDetailVO;
import com.es.www.kyl.bean.res.client.QuestionInfoVO;
import com.es.www.kyl.service.ExerciseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Estranger
 * @date 2025/8/13
 * description
 */
@Api(tags = "练习模块")
@RequiredArgsConstructor
@RestController
@RequestMapping("/client/exercise")
public class ExerciseController {

	private final ExerciseService exerciseService;

	@ApiOperation("开始做题")
	@PostMapping("/startQuestion")
	public R<QuestionInfoVO> startQuestion(@RequestBody DoExerciseBaseReq req) {
		return R.successResponse(exerciseService.startQuestion(req));
	}

	@ApiOperation("重做")
	@PostMapping("/redoQuestion")
	public R<QuestionInfoVO> redoQuestion(@RequestBody DoExerciseBaseReq req) {
		return R.successResponse(exerciseService.redoQuestion(req));
	}

	@ApiOperation("做错题")
	@PostMapping("/doWrongQuestion")
	public R<QuestionInfoVO> doWrongQuestion(@RequestBody DoExerciseBaseReq req) {
		return R.successResponse(exerciseService.doWrongQuestion(req));
	}

	@ApiOperation("提交做题结果")
	@PostMapping("/submitExerciseResult")
	public R<Void> submitQuestionResult(@RequestBody ExerciseResultReq req) {
		exerciseService.submitQuestionResult(req);
		return R.successCommonResponse();
	}

	@ApiOperation("根据题目id查询题目信息")
	@PostMapping("/listByQuestionIds")
	public R<List<QuestionDetailVO>> listByQuestionIds(@RequestBody ExerciseQueryReq req) {
		return R.successResponse(exerciseService.listByQuestionIds(req));
	}
}
